<extend name="Public:index" />
<block name="mycss">
<style>
.item_img{
  height: 80px;
}
</style>
</block>
<block name="main-content">
  <div class="container-fluid">
    <iframe name="ajaxifr" style="display:none;"></iframe>
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-body">
            <ul class="list-inline float-right d-flex">
               <li class="list-inline-item">
                 <button class="btn btn-info px-4 align-self-center waves-effect report-btn" data-toggle="modal" data-target="#editModal" data-backdrop="static" >
                        <i class="mdi  mdi-plus"></i>
                        新建模板</button>
              </li>
            </ul>
            <h4 class="mt-0 header-title">模板管理</h4>
            <div class="files mt-3">
              <ul class="nav nav-pills file-category mb-0" id="pills-tab" role="tablist">
              
                <volist  name="module_template" id="vo"  >
                <li class="nav-item file-category-block">
                    <a class="btn float-right btn-light btn-sm" onclick="delTemplate({$vo[id]})" ><i class="far fa-trash-alt"></i></a>
                    <a class="nav-link file-category-folder bg-soft-secondary text-muted" href="{:U('template_detail',array('id'=>$vo[id]))}">
                    <img src="__PUBLIC__/assets/images/device/ok/{$vo.cpn_type}_{$vo.group_code}.png" alt="" class="rounded item_img">
                    </a>
                 
                  <p class="mb-0 mt-1">
                   <a href="#" data-toggle="modal" data-target="#editModal" data-backdrop="static" data-id="{$vo.id}">{$vo.template_name} </a>
                </li>
                </volist>

              </ul>
            </div>
          </div>
          <!--end card-body-->
        </div>
        <!--end card-->
      </div> <!-- end col -->
   
    </div> <!-- end row -->
    <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <form class="" method="post" action="{:U('editTemplate')}" target="ajaxifr">
                <div class="modal-content">
                </div>
            </form>
        </div>
    </div>
  </div><!-- container -->

</block>
<block name="myscript">
 <script>
    $('#editModal').on('show.bs.modal', function (e) {

        var obj = $(e.relatedTarget);
        var id = obj.data('id');
        var url = "{:U('editTemplate',array('module_id'=>$module_id),'')}/id/" + id;
        $.ajax({
            type: 'GET',
            url: url
        }).then(function (data) {
            $('.modal-content').html(data);

        });
    });
    function delTemplate(id){
            var url = "{:U('delTemplate')}";
            if(confirm("确认删除此模板吗？")){
                $.get(url, {id: id}, function(res){
                    if(res == '1'){
                        window.location.reload();
                    }
                });
            }
        }

      
    </script>
</block>